from django.db import models

# Create your models here.
from django.core import validators
class Article(models.Model):
    title = models.CharField(max_length=10,validators=[validators.MinLengthValidator(limit_value=3)])
    content = models.TextField()
    author = models.CharField(max_length=100)
    category = models.CharField(max_length=100)
    create_time = models.DateTimeField(auto_now_add=True)


class Book(models.Model):
    name = models.CharField(max_length=100)
    pub_time = models.DateTimeField(auto_now_add=True)
    price = models.FloatField(default=0)
    # 外键的使用
    author = models.ForeignKey('Author', on_delete=models.CASCADE)

class Author(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()
    sex = models.CharField(max_length=20)
    class Meta:
        db_table = 'new_author'
        ordering = ['id']


class people(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()

    class Meta:
        db_table = 'people'

class peopleExtension(models.Model):
    birthday = models.DateField()
    people = models.OneToOneField(people, on_delete=models.CASCADE)

class countries(models.Model):
    name = models.CharField(max_length=100)
    people = models.ManyToManyField(peopleExtension)

class prosession(models.Model):
    name = models.CharField(max_length=100)
    people = models.ForeignKey('people', on_delete=models.CASCADE)









